<template>
	<view class="beijingse">
		<view class="margin_top mainpadding ffffff" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<!-- openfp_status开票状态1未开票，2开票中，3已开票，4拒绝开票 -->
				<view class="titletext fonweight xiaohong">{{item.price}}</view>
				<view class="strongtext xiaolv textright" v-if="item.status==2 && item.openfp_status==1">已完成</view>
				<view class="strongtext xiaohuang textright" v-if="item.openfp_status==2">开票中</view>
				<view class="strongtext xiaolv textright" v-if="item.openfp_status==3">已开票</view>
				<view class="strongtext xiaohong textright" v-if="item.openfp_status==4">拒绝开票</view>
				<view class="strongtext xiaohuang textright" v-if="item.status==1">审核中</view>
				<view class="strongtext xiaohong textright" v-if="item.status==3">已拒绝</view>
			</view>
			<view class="flexbetween margin_top" v-if="item.pay_type==30">
				<view class="xiaohei main_size">打款凭证</view>
				<view class="" style="width: 120rpx;height: 120rpx;position: relative;" @click="lbtpriview(0,[item.dk_image_text])">
					<image :src="item.dk_image_text" class=" radius" style="width: 100%;height: 100%;" mode=""></image>
				</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="xiaohui strongtext">{{item.createtime_text}}</view>
				<view class="xiaohong trashbtn smalltext"
					v-if="item.status==2 && (item.openfp_status==1 || item.openfp_status==4)"
					@click="jumpdetail('/pages/tab4/shenqingkp?id=',item.id)">申请开票</view>
				<view class="xiaohong trashbtn smalltext" v-if="item.openfp_status==3" @click="downfile(item.fp_url_text)">查看发票</view>
			</view>
			<view class="margin_top xiaohui strongtext" v-if="item.bz">{{item.bz}}</view>
			<view class="margin_top xiaohui strongtext" v-if="item.fp_bz && item.openfp_status!=3">拒开原因：{{item.fp_bz}}
			</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			downfile(url) {
				var that = this
				//加载框动画
				uni.showLoading({
					title: '请稍后……'
				});
				uni.downloadFile({
					url:url , //下载地址接口返回
					success: (data) => {
						if (data.statusCode === 200) {
							//隐藏加载框
							uni.hideLoading();
							//文件保存到本地
							uni.saveFile({
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									//自动打开文档查看
									var filePath = res.savedFilePath;
									uni.openDocument({ //新开页面打开文档，支持格式：doc, xls, ppt, pdf, docx, xlsx, pptx。
										filePath: filePath,
										showMenu: true,
										success: function(res) {}
									});
								}
							});
						}
					},
					fail: (err) => {
						console.log(err);
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '文件下载失败',
						});
					},
				});
			},
			init(isPage, page) {
				let _this = this
				let url = "/api/user/yjnbmoneyRechargeIndex"
				let data = {
					page: page || 1,
					limit: _this.limit,
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiahuaxian:last-child {
		padding-bottom: 0;
		border: none;
	}

	.shangbj {
		margin-top: 30rpx;
	}

	.shangbj:first-child {
		margin-top: 0rpx;
	}

	.editbtn {
		padding: 10rpx 30rpx;
		border-radius: 10rpx;
		background-color: #c1282e;
	}

	.trashbtn {
		padding: 10rpx 30rpx;
		border-radius: 10rpx;
		border: 1rpx solid #c1282e;
	}
</style>